package com.cloudsigns.factorymanager2.engineering.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.project.utils.ConstantUtil;

/**
 * Created by tony on 2018/5/15.
 */

public class EngineeringFeedBackForExceptionStateActivity extends Activity implements View.OnClickListener {
    private RelativeLayout rl_back;
    private TextView tv_title;
    private TextView tv_project_name, tv_engineering_name;
    private TextView btn_engineering_info;
    private OrderParentBean orderParentBean;
    private final String TAG = EngineeringFeedBackForExceptionStateActivity.class.getSimpleName();


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.layout_engineeringfeedback_for_exception_state);


        init();

        Intent mIntent = getIntent();
        if (null != mIntent) {
            orderParentBean = (OrderParentBean) mIntent.getSerializableExtra(ConstantUtil.KEY_1);
        }

        initData();
    }

    private void init() {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        tv_project_name = findViewById(R.id.tv_project_name);
        tv_engineering_name = findViewById(R.id.tv_engineering_name);
        btn_engineering_info = findViewById(R.id.btn_engineering_info);


        tv_title.setText("反馈信息");

        rl_back.setOnClickListener(this);
        btn_engineering_info.setOnClickListener(this);
    }

    private void initData() {
        if (null != orderParentBean) {
            tv_project_name.setText(orderParentBean.getProjectName());
            tv_engineering_name.setText("/" + orderParentBean.getEngineeringName());
        }
    }

    @Override
    public void onClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
            case R.id.btn_engineering_info:
                mIntent = new Intent(EngineeringFeedBackForExceptionStateActivity.this, ViewEngineeringInstallOrderDetailActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
                mIntent.putExtra(ConstantUtil.KEY_2, orderParentBean);
                startActivity(mIntent);
                break;


        }
    }
}
